<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWorkflowV2OrderNodeHandlersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('workflow_v2_order_node_handlers', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('workflowTemplateNodeId')->default(0)->comment('workflow_v2_template_nodes.id');
            $table->unsignedInteger('workflowOrderNodeId')->default(0)->comment('workflow_v2_order_nodes.id');
            $table->unsignedTinyInteger('handlerType')->default(0)->comment('处理人类型 1固定id 2督导 3省总 4加盟商');
            $table->unsignedInteger('handlerUid')->default(0)->comment('处理人uid');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->tinyInteger('isDeleted')->default(0);
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '审批流v2 - 节点处理人';

            $table->index('workflowOrderNodeId', 'workflowOrderNodeId');
            $table->index(['workflowTemplateNodeId'], 'idx_workflowTemplateNodeId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('workflow_v2_order_node_handlers');
    }
}
